export default {
  namespace: 'reset',
  state:{
   // 先展示样式 日后接口通需要改为默认false
   modalControl:false,
   code: {
     count: 60,
     isClick: false,
     content: '',
     modalControl: false,
   },
  },
  subscriptions: {
    setup ({ dispatch, history }) {
      history.listen((location) => {
        // 用户刷新页面时候请求编排接口
        if (location.pathname === '/resetPassword') {
          dispatch({
            type: 'modules/getModules',
            payload: {
              pathname: '',
              businessId: '1231241200',
              process: 'resetPassword',
              title: '重置交易密码'
            }
          })
        }
      })
    }
  },
  effects: {
    *modalControlAction ( { payload } , { put }) {
      yield put({
        type: 'changeModal',
        ...payload
      })
    },
    *getCode ( { payload }, { put }) {
      yield put( {
        type: 'changeCode',
        payload
      })
    },
  },
  reducers: {
    // 修改modal的显示状态
    // changeModal (state, { payload }) {
    //   return {
    //     ...state,
    //     ...payload
    //   }
    // },
    // 修改验证码
    changeCode (state, { payload }) {
      return {
        ...state,
        ...payload
      }
    },
    changeModal (state, { payload }) {
      return {
        ...state,
        ...payload
      }
    }
  }
}